﻿using System;
using System.Collections.Generic;

namespace CodeFirst.Data
{
    public sealed class Comment
    {
        public int Id { get; set; }
        public DateTime DateCreated { get; set; }
        public string Content { get; set; }
        public int PostId { get; set; }
        public Post Post { get; set; }
    }

    public sealed class Post
    {
        public int Id { get; set; }
        public string Title { get; set; }
        public DateTime DateCreated { get; set; }
        public string Content { get; set; }
        public int BlogId { get; set; }
        public ICollection<Comment> Comments { get; set; }

        public void AddComment(Comment comment)
        {
            if (Comments == null)
            {
                Comments = new List<Comment>();
            }
            Comments.Add(comment);
        }
    }

    public sealed class Blog
    {
        public int Id { get; set; }
        public string Title { get; set; }
        public string Owner { get; set; }
        public ICollection<Post> Posts { get; set; }

        public void AddPost(Post post)
        {
            if (Posts == null)
            {
                Posts = new List<Post>();
            }
            Posts.Add(post);
        }
    }
}
